package com.leyu.mall.site.news.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.leyu.mall.common.facade.ICmsChannelFacade;
import com.leyu.mall.common.facade.ICmsContentFacade;
import com.leyu.mall.common.facade.ICmsSlideFacade;
import com.leyu.mall.common.facade.IGoodsBrandFacade;
import com.leyu.mall.common.facade.IGoodsCategoryFacade;
import com.leyu.mall.domain.cms.CmsSite;
import com.leyu.mall.domain.goods.GoodsBase;
import com.leyu.mall.domain.goods.GoodsCategory;
import com.leyu.mall.service.cms.ICmsNewsService;
import com.leyu.mall.service.cms.ICmsShopConfigService;
import com.leyu.mall.service.cms.ICmsSiteService;
import com.leyu.mall.service.goods.IGoodsBaseService;
import com.leyu.mall.service.news.ISiteNewsService;
import com.leyu.mall.service.sale.ISaleRankListService;
 
 
@Controller
@Scope(value = "prototype")
@RequestMapping("news/footer")
public class NewsController {

	
//	@Autowired
//	private ICmsNewsFacade cmsNewsFacade;
//	
	@Autowired
	private ISiteNewsService siteNewsService;
//	@Autowired
//	private IGoodsBrandFacade goodsBrandFacade;
//	
//	@Autowired
//	private ICmsChannelFacade cmsChannelFacade;
//
//	@Autowired
//	private ICmsContentFacade cmsContentFacade;
//	
//	@Resource(name = "saleRankListServiceImpl")
//	private ISaleRankListService saleRankListFacade;
//	
//	@Autowired
//	private ICmsSlideFacade cmsSlideFacade;
////	@Autowired
////	private IGoodsBaseFacade goodsBaseFacade;
//	
//	@Autowired
//	private IGoodsBaseService goodsBaseFacade;
//	
//	@Autowired
//	private IGoodsCategoryFacade  goodsCategoryFacade;
//	
//	@Autowired
//	private ICmsSiteService  cmsSiteServiceImpl;
	@Autowired
	private ICmsNewsService  cmsNewsServiceImpl;

	@ExceptionHandler(Exception.class)
	public String exception(Exception e, HttpServletRequest request) {
		request.setAttribute("exception", e);
		return "/error.html";
	}

	@RequestMapping("/bottom")
	public String bottom(Model model) {
		return "/bottom.html";
	}
	@RequestMapping("/header")
	public String header(Model model) {
		return "/header.html";
	}
	@RequestMapping("/menu")
	public String menu(Model model) {
		return "/menu.html";
	}
		
	@RequestMapping(value = "", method = RequestMethod.GET)
	
	public String index(Model model) {
		 
//			model.addAttribute("adlist", cmsContentFacade.getDisplayADList());
//			model.addAttribute("ranklist", saleRankListFacade
//					.getAllSaleRankList());
//			model.addAttribute("list", cmsChannelFacade.getDisplayChannelList());
			try {
				model.addAttribute("newslist", siteNewsService.getDisplayNewsList());
			 
				model.addAttribute("newslist2", cmsNewsServiceImpl.getAllCmsNews());
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
//			model.addAttribute("lefthotgoodslist", goodsBaseFacade.getHotGoodsList());
//			model.addAttribute("leftnewgoodslist",goodsBaseFacade.getNewGoodsList() );
//			model.addAttribute("groupgoodslist", goodsBaseFacade.getGroupGoodsList());
//			model.addAttribute("hotbrandlist",goodsBrandFacade.getAllGoodsBrand());
//			model.addAttribute("promotiongoodslist", goodsBaseFacade.getPromotionGoodsList());
//			
		 
		
		 
		return "news/news.html";
	 
	}
	


}
